package leetcode.treeCode.week5.leetcode_538;

class Solution {
    private  int sum = 0;
    public TreeNode convertBST(TreeNode root) {
        dfs(root);
        return root;
    }
    private void dfs(TreeNode node){
        if (node == null) {
            return ;
        }
        dfs(node.right);
        sum += node.val;
        node.val = sum;
        dfs(node.left);
    }
}